package io.renren.common.utils;

import cn.hutool.crypto.digest.DigestAlgorithm;
import cn.hutool.crypto.digest.Digester;

import java.nio.charset.StandardCharsets;

public class DigestUtil {
    //sha256加密，带salt
    public static String sha256(String str, String salt) {
        Digester digester = new Digester(DigestAlgorithm.SHA256);
        digester.setSalt(salt.getBytes());
        return digester.digestHex(str);
    }

    public static String sha256Hex(String str) {
        return new Digester(DigestAlgorithm.SHA256).digestHex(str, StandardCharsets.UTF_8);
    }
}
